// app.js
App({
  onLaunch() {
    this.overShare();
    //获取状态栏的高度
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.globalData.statusBarHeight = res.statusBarHeight;
      }
    })
    if(wx.getStorageSync('userinfo')){
      
       that.globalData.userinfo = wx.getStorageSync('userinfo')
       let param = {
        phone: app.globalData.userinfo.usermobile
      }
      api.get_userInfo(param).then(function(res){
          if(res.code == '1'){
            that.globalData.userinfo = '';
          }else{   
            wx.setStorageSync('userinfo', res.data)
            app.globalData.userinfo = res.data;
          }
      })

    }
  },
  //重写分享方法
  overShare: function () {
    //监听路由切换
    //间接实现全局设置分享内容
    wx.onAppRoute(function (res) {
      //获取加载的页面
      let pages = getCurrentPages(),
        //获取当前页面的对象
        view = pages[pages.length - 1],
        data;
      if (view) {
        data = view.data;
        if (!data.isOverShare) {
          data.isOverShare = true;
          view.onShareAppMessage = function () {
            //你的分享配置
            return {
              title: '安庆商会小程序',
              desc: ''
            };
          }
        }
      }
    })
  },
  globalData: {
    statusBarHeight: 0,
    siteUrl : 'https://pbootcms.symbol365.com/',
    // 可删除图片
    imagesUrl: '/images/pic/',
    userinfo: "",
    uploadUrl:"https://pbootcms.symbol365.com/api.php?p=/UploadFile/index"
  }
})
